//
//  CategoryListLeftCell.m
//  ABSallRec
//
//  Created by 我演示 on 2019/11/15.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

#import "CategoryListLeftCell.h"

@interface CategoryListLeftCell ()

/**leftView*/
@property(nonatomic,weak) UIView *selectView ;
/**label*/
@property(nonatomic,weak) UILabel *titleNameLabel ;


@end


//#define static NSString *
@implementation CategoryListLeftCell

+(instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *cellString = @"CategoryListLeftCell";
    
    CategoryListLeftCell *cell = [tableView dequeueReusableCellWithIdentifier:cellString];
    if (cell == nil) {
        cell = [[CategoryListLeftCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellString];
    }
    cell.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self makeUpUI];
        [self makeUpSubviews];
    }
    return self;
    
}

-(void)makeUpUI{
    UIView *showView = [[UIView alloc] init];
    showView.backgroundColor = [UIColor colorWithHexString:@"#333333"];
    [self.contentView addSubview:showView];
    self.selectView = showView ;
    
    UILabel *titleNameLabel = [[UILabel alloc] initWithTextString:@"名称" andTextColor:[UIColor colorWithHexString:@"#333333"] andTextFont:15];
    titleNameLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:15];
    [self.contentView addSubview:titleNameLabel];
    self.titleNameLabel = titleNameLabel;
    
}
-(void)makeUpSubviews {
    [self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(3);
        make.top.equalTo(self.mas_top).offset(8);
        make.bottom.equalTo(self.mas_bottom).offset(-8);
        make.width.offset(2);
    }];
    
    [self.titleNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.selectView.mas_right).offset(7);
        make.top.bottom.right.equalTo(self).offset(0);
  
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)setModel:(ABSCategoryFirstModel *)model {
    _model = model;
//    self.textLabel.text = model.categoryName;
    self.titleNameLabel.text = model.categoryName;
    
    if (model.isSelected == YES ) {
         self.backgroundColor = UIColor.whiteColor;
        self.selectView.hidden = NO;
        self.titleNameLabel.textColor = [UIColor colorWithHexString:@"#333333"];
     }else{
         self.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
          self.selectView.hidden = YES;
           self.titleNameLabel.textColor = [UIColor colorWithHexString:@"#666666"];
     }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
